package com.NeuglsWorkStudio.UI.FormElement.Component
{
	import com.NeuglsWorkStudio.UI.FormElement.Config.TConfig;
	import com.NeuglsWorkStudio.UI.FormElement.Config.TIconButtonConfig;
	
	public class TIconButton extends TCustomButton
	{
		public function TIconButton(AConfig:TConfig)
		{
			super(AConfig);
		}
		
		public function IconButtonConfig():TIconButtonConfig{
			return _FConfig as TIconButtonConfig;
		}
		
		override protected function DrawIconAndLabel():void{
			var LastX:Number=5;
			var LastY:Number=5;
			var Margin:Number=5;
			if(_FIcon){
				switch(IconButtonConfig().IconAlign){
					case TIconButtonConfig.IconBottom:
						_FLabel.y=LastY;
						_FLabel.x=LastX;
						LastY+=_FLabel.height+Margin;
						_FIcon.x=LastX;
						_FIcon.y=LastY;
						break;
					case TIconButtonConfig.IconLeft:
						_FIcon.x=LastX;
						_FIcon.y=LastY;
						LastX+=_FIcon.width+Margin;
						_FLabel.x=LastX;
						_FLabel.y=LastY;
						break;
					case TIconButtonConfig.IconRight:
						_FLabel.y=LastY;
						_FLabel.x=LastX;
						LastX+=_FLabel.width+Margin;
						_FIcon.x=LastX;
						_FIcon.y=LastY;
						break;
					case TIconButtonConfig.IconTop:
						_FIcon.x=LastX;
						_FIcon.y=LastY;
						LastY+=_FIcon.height+Margin;
						_FLabel.x=LastX;
						_FLabel.y=LastY;
						break;
				}	
			}else{
				_FLabel.x=LastX;
				_FLabel.y=LastY;
			}
			
			
		}
	}
}